﻿Ext.define('app.prm.project_task.ReplyNote',
{
    extend: 'Ext.window.Window',
    autoScroll: true,
    modal: true,
    title: '答案描述',
    width: 600,
    height: 400,
    layout: 'fit',
    bodyStyle: 'padding:2px',
    projectTaskId: 0,
    initComponent: function () {
        var me = this;
        me.items = [me.getForm()];

        me.buttons = [
            { text: '确定', handler: function () { me.onSave(); } },
            { text: '取消', handler: function () { me.close(); } }
        ];
        me.callParent();
    },
    getForm: function () {
        var me = this;
        if (!this.form) {
            this.form = new Ext.form.FormPanel(
            {
                border: false,
                frame: false,
                fieldDefaults: {
                    width: '95%',
                    labelWidth: 80,
                    labelAlign: "right",
                    margin: 6
                },
                bodyStyle: 'padding:5px',
                items: [
                    {
                        xtype: 'filefield', name: 'taskFile', buttonText: '选择', fieldLabel: '答案附件'
                    },
                    { xtype: 'hidden', value: me.projectTaskId, name: 'projectTaskId' },
                    {
                        xtype: 'textarea',
                        height: 200,
                        name: 'note',
                        fieldLabel: '描述'
                    }
                ]
            });
        }
        return this.form;
    },
    onSave: function () {
        var me = this;
        var f = me.form.query("filefield[name=taskFile]")[0]
        var json = me.getForm().getValues();

        if (f.value == "" && json.note == "") {
            Ext.Msg.alert('系统提示', '描述和附件必须填写一个');
            return false;
        }
        me.form.getForm().submit({
            url: '/api/services/app/projectTask/CreateReply',
            success: function (form, response)
            {
                me.fireEvent("savesuccess");
            }
        });
    }
});